home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Src / Mod / AppIcon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-05  |  20.3 KB  |  878 lines

  1. /******************************************************************************
  2.  
  3.     MODULE
  4.     AppIcon.c
  5.  
  6.     DESCRIPTION
  7.     XDME Command Module
  8.  
  9.     to form a Workbench AppIcon for the XDME process
  10.  
  11.     NOTES
  12.     the "COMMAND"-lines have a specail meaning (see STATIC_COM)
  13.     the SPC_VAR-section has a special meaning (see there)
  14.  
  15.     BUGS
  16.     none known
  17.  
  18.     TODO
  19.     tell me
  20.  
  21.     EXAMPLES
  22.  
  23.     SEE ALSO
  24.  
  25.     AUTHOR
  26.     Bernd "0" Noll (b_noll@informatik.uni-kl.de)
  27.  
  28.     HISTORY
  29.     21-09-94 b_noll created
  30.     01-10-94 b_noll introduced DEFMESSAGE
  31.     27-11-94 b_noll first preparations for multiicon support
  32.     03-12-94 b_noll removed `defs.h'
  33.  
  34. ******************************************************************************/
  35.  
  36.  
  37. /**************************************
  38.           Includes
  39. **************************************/
  40.  
  41. /* #include "defs.h" */
  42.  
  43. #include <workbench/icon.h>
  44. #include <workbench/startup.h>
  45. #include <workbench/workbench.h>
  46.  
  47. #include <proto/exec.h>
  48. #include <proto/icon.h>
  49. #include <proto/wb.h>
  50.  
  51. #include <stdio.h>
  52. #include "xdme_base.h"
  53.  
  54. /**************************************
  55.         Global Variables
  56. **************************************/
  57.  
  58.  
  59. Prototype UBYTE         *APIC_IconTitle;
  60. Prototype UBYTE         *APIC_IconFile;
  61. Prototype UBYTE         *APIC_ActionDblClick;
  62. Prototype UBYTE         *APIC_ActionDrop;
  63. //Prototype UBYTE           APIC_Active;
  64. Prototype ULONG          APIC_SigMask;
  65.  
  66. /**************************************
  67.       Internal Defines & Structures
  68. **************************************/
  69.  
  70. #define APIC_OK 0
  71. #define APIC_NOICON        -1
  72. #define APIC_NODISKOBJECT   -2
  73. #define APIC_NOPORT        -3
  74. #define APIC_max
  75.  
  76. #define APIC_BufferSize 500
  77.  
  78. /**************************************
  79.        Internal Variables
  80. **************************************/
  81.  
  82. struct DiskObject *APIC_DiskObject = NULL;
  83. APTR           APIC_Icon       = NULL;
  84. struct MsgPort      *APIC_Port       = NULL;
  85.  
  86. UBYTE          *APIC_IconTitle    = NULL;
  87. UBYTE          *APIC_IconFile    = NULL;
  88. UBYTE          *APIC_ActionDblClick    = NULL;
  89. UBYTE          *APIC_ActionDrop    = NULL;
  90.  
  91. //UBYTE          APIC_Active      = 0;
  92. ULONG           APIC_SigMask     = 0;
  93.  
  94. /**************************************
  95.        Internal Prototypes
  96. **************************************/
  97.  
  98.  
  99. /**************************************
  100.          Macros
  101. **************************************/
  102.  
  103. #define APIC_DefTitle        "XDME"
  104. #define APIC_DefIconFile    "XDME"
  105.  
  106. #define APIC_DefDblClick    "newwindow arpload"
  107. #define APIC_DefDrop        "newwindow newfile `%s'"
  108.  
  109. /**************************************
  110.          Implementation
  111. **************************************/
  112.  
  113.  
  114.  
  115. int APIC_Hide (void) {
  116.     if (!APIC_Icon)
  117.     return APIC_NOICON;
  118.  
  119.     if (APIC_Icon)
  120.     RemoveAppIcon(APIC_Icon);
  121.     APIC_Icon = NULL;
  122.  
  123.     if (APIC_DiskObject)
  124.     FreeDiskObject(APIC_DiskObject);
  125.     APIC_DiskObject = NULL;
  126.  
  127.     APIC_Active = 0;
  128.     return APIC_OK;
  129. } /* APIC_Hide */
  130.  
  131.  
  132. int APIC_Show (const UBYTE * iconfile, const UBYTE *icontitle) {
  133.     if (!APIC_Port)
  134.     return APIC_NOPORT;
  135.  
  136.     if ((APIC_DiskObject = GetDiskObject (APIC_IconFile)) == NULL) {
  137.     if (!getappname(tmp_buffer, sizeof(tmp_buffer)) ||
  138.        ((APIC_DiskObject = GetDiskObject (tmp_buffer)) == NULL)) {
  139.         if ((APIC_DiskObject = GetDefDiskObject (WBTOOL)) == NULL) {
  140.         APIC_Hide();
  141.         return APIC_NODISKOBJECT;
  142.         } /* if */
  143.     } /* if */
  144.     } /* if */
  145.  
  146.     APIC_Icon = AddAppIconA (NULL, NULL, APIC_IconTitle, APIC_Port, NULL, APIC_DiskObject, NULL);
  147.  
  148.     if (!APIC_Icon ) {
  149.     APIC_Hide();
  150.     return APIC_NOICON;
  151.     } /* if */
  152.  
  153.     APIC_Active = 1;
  154.     return APIC_OK;
  155. } /* APIC_Show */
  156.  
  157. #if 0
  158.  
  159.  
  160.  
  161.  
  162.  
  163. struct ApNode {
  164.     struct HNode       Node;
  165.     UBYTE          *IconTitle;
  166.     UBYTE          *IconFile;
  167.     struct DiskObject *DiskObject;
  168.     APTR           Icon;
  169.     BYTE           IconStatus;
  170.     UBYTE          *ClickAction;
  171.     UBYTE          *DropAction;
  172. }; /* struct  */
  173.  
  174. int APIC_Hide (struct ApNode *n) {
  175.     if (n->IconStatus != VISIBLE)
  176.     return APIC_ISHIDDEN;
  177.  
  178.     if (n->Icon)
  179.     RemoveAppIcon(n->Icon);
  180.     n->Icon = NULL;
  181.  
  182.     n->IconStatus = HIDDEN;
  183.     return HL_OK;
  184. } /* APIC_Hide */
  185.  
  186.  
  187. int APIC_Show (struct ApNode *n)
  188. {
  189.     if (n->IconStatus == VISIBLE)
  190.     return APIC_ISVISIBLE;
  191.  
  192.     if (!n->DiskObject) {
  193.     if ((n->DiskObject = GetDiskObject (n->IconFile)) == NULL) {
  194.         APIC_Hide(n);
  195.         return APIC_NODISKOBJECT;
  196.     } /* if */
  197.     } /* if */
  198.  
  199.     n->Icon = AddAppIconA (NULL, n, n->IconTitle, APIC_Port, NULL, n->DiskObject, NULL);
  200.     if (!n->Icon) {
  201.     APIC_Hide(n);
  202.     return APIC_NOICON;
  203.     } /* if */
  204.  
  205.     n->IconStatus = VISIBLE;
  206.     return HL_OK;
  207. } /* APIC_Show */
  208.  
  209.  
  210.  
  211.  
  212. int APIC_Dispose (struct ApNode *n)
  213. {
  214.     int rv;
  215.     if (in->Status == VISIBLE)
  216.     APIC_Hide (n);
  217.  
  218.     if ((rv = HL_Uninit(n)) != HL_OK)
  219.     return rv;
  220.  
  221.     if (n->DiskObject)
  222.     FreeDiskObject(n->DiskObject);
  223.     n->DiskObject = NULL;
  224.  
  225.     if (n->IconFile)
  226.     free(n->IconFile);
  227.     n->IconFile = NULL;
  228.  
  229.     if (n->IconTitle)
  230.     free(n->IconTitle);
  231.     n->IconTitle = NULL;
  232.  
  233.     if (n->DropAction)
  234.     free(n->DropAction);
  235.     n->DropAction = NULL;
  236.  
  237.     if (n->ClickAction)
  238.     free(n->ClickAction);
  239.     n->ClickAction = NULL;
  240.  
  241.     free(n);
  242.     return HL_OK;
  243. } /* APIC_Dispose */
  244.  
  245.  
  246. int APIC_New (const UBYTE *name, const UBYTE *ifile, const UBYTE *ititle)
  247. {
  248.     struct ApNode *n;
  249.  
  250.     if (n = malloc (sizeof (*n))) {
  251.     if ((rv = HL_Init (n, name, APIC_Root, HLF_SYSNODE)) != HL_OK) {
  252.         free (n);
  253.         return rv;
  254.     } /* if */
  255.     n->IconFile   = strdup (NULL, ifile);
  256.     n->IconTitle  = strdup (NULL, ititle);
  257.     n->IconStatus = HIDDEN;
  258.     if ((n->DiskObject = GetDiskObject (n->IconFile)) == NULL) {
  259.         n->IconStatus = NODOBJECT;
  260.     } /* if */
  261.  
  262.     return HL_OK;
  263.     } /* if */
  264.     return HL_NOMEM
  265. } /* APIC_New */
  266.  
  267.  
  268. DEFAUTOEXIT( APIC_Terminate )
  269. {
  270.     /* ---- delete the icons */
  271.     if (APIC_Root) {
  272.     struct DList *icons;
  273.     if ((icons = HL_LockSubs(APIC_Root)))
  274.         DLL_Scan(icons, APIC_Dispose, NULL);
  275.     HL_Dispose (APIC_Root);
  276.     } /* if */
  277.  
  278.     { /* ---- drop all waiting messages */
  279.     struct Message *msg;
  280.     while (msg = GetMsg(APIC_Port)) {
  281.         ReplyMsg (msg);
  282.     } /* while */
  283.     }
  284.  
  285.     /* ---- close the port */
  286.     if (APIC_Port)
  287.     DeleteMsgPort(APIC_Port);
  288.     APIC_Port = NULL;
  289.  
  290. } /* APIC_Terminate */
  291.  
  292.  
  293. DEFAUTOINIT( APIC_Initialize )
  294. {
  295. //puts (__FILE__);
  296.  
  297.     APIC_Root = HL_SystemList ("*AppIcons*");
  298.     APIC_Port        = CreateMsgPort();
  299.  
  300.     if ( !APIC_Port || !APIC_Root ) {
  301.     APIC_Terminate();
  302.     return;
  303.     } /* if */
  304.  
  305.     APIC_SigMask = 1 << APIC_Port->mp_SigBit;
  306.  
  307. } /* APIC_Initialize */
  308.  
  309.  
  310.  
  311. #endif
  312.  
  313.  
  314.  
  315.  
  316.  
  317. /*************************************************
  318.     Entry & Exit Code
  319. *************************************************/
  320.  
  321.  
  322. DEFAUTOEXIT( APIC_Terminate )
  323. {
  324.     /* ---- hide the icon */
  325.     //DLL_Scan(APIC_Icons, APIC_Hide, NULL);
  326.     APIC_Hide();
  327.  
  328.     { /* ---- drop all waiting messages */
  329.     struct Message *msg;
  330.     while (msg = GetMsg(APIC_Port)) {
  331.         ReplyMsg (msg);
  332.     } /* while */
  333.     }
  334.  
  335.     /* ---- close the port */
  336.     if (APIC_Port)
  337.     DeleteMsgPort(APIC_Port);
  338.     APIC_Port = NULL;
  339.  
  340. } /* APIC_Terminate */
  341.  
  342.  
  343. DEFAUTOINIT( APIC_Initialize )
  344. {
  345. //puts (__FILE__);
  346.     APIC_Port        = CreateMsgPort();
  347.     APIC_IconTitle    = strdup (APIC_DefTitle);
  348.     APIC_IconFile    = strdup (APIC_DefIconFile);
  349.     APIC_ActionDrop    = strdup (APIC_DefDrop);
  350.     APIC_ActionDblClick = strdup (APIC_DefDblClick);
  351.  
  352.     if (!APIC_Port || !APIC_IconTitle || !APIC_IconFile || !APIC_ActionDrop || !APIC_ActionDblClick ) {
  353.     APIC_Terminate();
  354.     return;
  355.     } /* if */
  356.  
  357.     APIC_SigMask = 1 << APIC_Port->mp_SigBit;
  358.  
  359. } /* APIC_Initialize */
  360.  
  361.  
  362. /*************************************************
  363.     Application Interface
  364. *************************************************/
  365.  
  366.  
  367. /*
  368. ** Explain an APIC related error
  369. */
  370. int APIC_Error (int code, const UBYTE *command, ...) {
  371.     switch (code) {
  372.     case APIC_OK:
  373.     return RET_SUCC;
  374.     case APIC_NOICON:
  375. DEFMESSAGE( _APIC_appicon_not_shown, "%s:\nAppIcon not shown!" )
  376.     error (_APIC_appicon_not_shown, command);
  377.     break;
  378.     case APIC_NODISKOBJECT:
  379. DEFMESSAGE( _APIC_icon_not_created, "%s:\nIcon not created!" )
  380.     error (_APIC_icon_not_created, command);
  381.     break;
  382.     case APIC_NOPORT:
  383. DEFMESSAGE( _APIC_module_inactive, "%s:\nAppIcon Module not active!" )
  384.     error (_APIC_module_inactive, command);
  385.     break;
  386.     default:
  387. DEFMESSAGE( _APIC_internal_error, "%s:\nAppIcon Internal Error!" )
  388.     error (_APIC_internal_error, command);
  389.     } /* switch */
  390.     return RET_FAIL;
  391. } /* APIC_Error */
  392.  
  393.  
  394. /*
  395. **  Get a message from the AppIcon
  396. */
  397. Prototype void APIC_Control (void);
  398. void APIC_Control (void) {
  399.     struct AppMessage *msg;
  400.  
  401.     while (msg = (struct AppMessage *)GetMsg (APIC_Port)) {
  402.     if (!msg->am_NumArgs) {
  403.         buffered_do_command (APIC_ActionDblClick);
  404.     } else {
  405.         char *buffer = malloc (APIC_BufferSize);
  406.         if (buffer) {
  407.         int i;
  408.         for (i = 0; i < msg->am_NumArgs; ++i) {
  409.             /* ---- getpathto() is found in XDME/Src/Subs.c */
  410.             if (getpathto(msg->am_ArgList[i].wa_Lock, msg->am_ArgList[i].wa_Name, tmp_buffer)) {
  411.             sprintf (buffer, APIC_ActionDrop, tmp_buffer, tmp_buffer, tmp_buffer, tmp_buffer);
  412.             do_command(buffer);
  413.             } else {
  414.             /* ---- file not found - und nun? */
  415.             } /* if */
  416.         } /* for */
  417.         } else {
  418.         nomemory();
  419.         } /* if */
  420.  
  421.     } /* if */
  422.  
  423.     ReplyMsg ((struct Message *)msg);
  424.     } /* while */
  425. } /* APIC_Control */
  426.  
  427.  
  428. /*************************************************
  429.     Fragments of other modules
  430. *************************************************/
  431.  
  432. #ifdef MAIN_C
  433.  
  434. DEFSIGHANDLER( APIC_SigMask, APIC_Control(); )
  435.  
  436. #endif
  437.  
  438.  
  439. /***************************************************
  440.         COMMAND INTERFACE
  441. ***************************************************/
  442.  
  443. /*DEFHELP #cmd special APPICON - The AppIcon Interface */
  444. //DEFUSERCMD( "AppIconShow", 0, 0, void, do_apicshow, (void),)
  445. Prototype int do_apicshow (void);
  446. int do_apicshow (void) {
  447.     return APIC_Error( APIC_Show(APIC_IconFile, APIC_IconTitle), av[0]);
  448. } /* do_apicshow */
  449.  
  450. //DEFUSERCMD( "AppIconHide", 0, 0, void, do_apichide, (void),)
  451. Prototype int do_apichide (void);
  452. int do_apichide (void) {
  453.     return APIC_Error(APIC_Hide(), av[0]);
  454. } /* do_apichide */
  455.  
  456.  
  457.  
  458. /*DEFLONG #long APPICON
  459.  
  460. That Package allows use of a Workbench AppIcon.
  461. Currently the whole package is conrolled via some special
  462. variables, not via commands;
  463. the following five variables are used:
  464.  
  465.     $appicon - (BOOL) the status of the appicon:
  466.      setting it to "1" makes the AppIcon appear,
  467.      setting it to "0" makes the AppIcon disappear.
  468.  
  469.     $appiconname - (FILE) the icon to be used for the AppIcon Image;
  470.     plase note, that modification of that variable currently
  471.     only has effect after the NEXT appearance of the AppIcon,
  472.     the visible Image is not changed.
  473.     Defaults to "XDME".
  474.  
  475.     $appicontitle - (STRING) the titlestring to be used in connection
  476.     with the AppIcon (the same limit as for $appiconname)
  477.     Defaults to "XDME".
  478.  
  479.     $appicondropaction - (COMMAND) the command to be executed,
  480.     whenever another icon is dropped onto the AppIcon; any
  481.     "%s" in that variable are expanded to the full name of
  482.     the dropped icon (w/ sprintf).
  483.     Defaults to "newwindow newfile `%s'".
  484.  
  485.     $appiconclickaction - (COMMAND) the command to be executed,
  486.     whenever user doubleclicks on the AppIcon.
  487.     Defaults to "newwindow arpload".
  488.  
  489. */
  490.  
  491.  
  492.  
  493.  
  494. #undef STATIC_COM
  495. /***********************************************************
  496.     The STATIC_COM section has currently _2_ purposes:
  497. =58 abort sub $arg1 $tabstop) if c=59 abort firstnb if ca (checkexistance $currentword ($blockbeginner) (add $arg1 $tabstop))
  498. a (checkexistance $currentword ($blockbeginner) (add $arg1 $tabstop))
  499. top))
  500.     source tree of a tool
  501.       - to achie
  502.     - we can use the "COMMAND(...)" lines to generate
  503.       a List of all commands of a certain application,
  504.       (static solution)
  505.     - we can add AUTOINIT and AUTOEXIT functions
  506.       which add those COMMAND lines to a global
  507.       database themselfes (dynamic solution)
  508.       that way is very interesting in case of using
  509.       a split application, cluttered in many small
  510.       modules, which can be activated or removed
  511.       by user request
  512.  
  513.     Since Dynamic method means too much overhead to be of
  514.     any use for the XDME, we will probably probably never
  515.     use the DYNAMIC solution, and for that reason it might
  516.     be of more use to put those command lines to the
  517.     functions, which implement those commands.
  518. ***********************************************************/
  519. #ifdef STATIC_COM
  520. #define COMMAND(n,a,f,p) /* these lines cannot be translated here! */
  521.  
  522.     /* COMMAND("", , , ) */
  523.  
  524.     DEFFLAG( 94-09-19, APIC_Active, 0 )
  525.  
  526.  
  527. #endif
  528.  
  529.  
  530. #undef SPC_VAR
  531. /***********************************************************
  532.     The SPC_VAR section has only one purpose:
  533.       - it contains descriptions for all special
  534.     variables of the module, which are of interest
  535.     for the user - to change them or to ask their
  536.     values via variable interface.
  537.     that section shall _never_ be considered C-Source
  538.     (for that reason the "#undef" is put just before)
  539.     but it is scanned by an external parser in order
  540.     to produce a list of all Special variables and
  541.     their access functions in a seperate File.
  542. ***********************************************************/
  543. #ifdef SPC_VAR
  544.  
  545. generic global bit appicon = %{
  546.     reference = "APIC_Active";
  547.     set       = %[ { char inter; inter = test_arg(value, $(REFERENCE)); if (inter != $(REFERENCE)) if (inter) do_apicshow(); else do_apichide(); } %];
  548.     help      = %[ the IsVisible status of the AppIcon. %];
  549.     gendate   = "21-09-94/1";
  550.     initval   = "0";
  551. %};
  552.  
  553. generic global str appicontitle = %{
  554.     reference = "APIC_IconTitle";
  555.     set       = %[ $(REFERENCE) = strrep ($(REFERENCE), value); %];
  556.     help      = %[ the titlestring to te used when next time showing the AppIcon. %];
  557.     gendate   = "21-09-94/2";
  558.     initval   = %[ "XDME" %];
  559. %};
  560.  
  561. generic global str appiconname = %{
  562.     reference = "APIC_IconFile";
  563.     set       = %[ $(REFERENCE) = strrep ($(REFERENCE), value); %];
  564.     help      = %[ the iconfile to be used when next time showing the AppIcon. %];
  565.     gendate   = "21-09-94/3";
  566.     initval   = %[ "PROGDIR:XDME" %];
  567. %};
  568.  
  569. generic global str appo·ondropaction = %{
  570.     reference = "APIC_ActionDrop";
  571.     set       = %[ $(REFERENCE) = strrep ($(REFERENCE), value); %];
  572.     help      = %[ the command to the called, whenever an icon is dropped onto the AppIcon %];
  573.     gendate   = "21-09-94/4";
  574.     initval   = %[ "newwindow newfile `%s'" %];
  575. %};
  576.  
  577. generic global str appiconclickaction = %{
  578.     reference = "APIC_ActionDblClick";
  579.     set       = %[ $(REFERENCE) = strrep ($(REFERENCE), value); %];
  580.     help      = %[ the command to be called, whenever the user doubleclicks onto the AppIcon. %];
  581.     gendate   = "21-09-94/5";
  582.     initval   = %[ "newwindow arpload" %];
  583. %};
  584.  
  585.  
  586. #endif /* SPC_VAR */
  587.  
  588. /******************************************************************************
  589. *****  END AppIcon.c
  590. ******************************************************************************/
  591.  
  592.  
  593.  
  594. #if 0
  595.  
  596. struct AppIcon {
  597.     UBYTE          *IconTitle;
  598.     UBYTE          *IconFile;
  599.     struct DiskObject *DiskObject;
  600.     APTR           Icon;
  601.     UBYTE          *ClickAction;
  602.     UBYTE          *DropAction;
  603.     BYTE           IconStatus;
  604. }; /* struct AppIcon */
  605.  
  606. struct HLClass appiconClass = {
  607.     HL_RootClass;
  608.     sizeof (struct AppIcon);
  609.     APIC_Dispatcher;
  610. };
  611.  
  612. ULONG APIC_Dispatcher (HObject *o, APTR cl, Msg msg)
  613. {
  614.     struct AppIcon *inst = HINST_DATA(o,cl);
  615.     struct TagItem *ti, *tstate;
  616.  
  617.     switch (msg->AttributeID) {
  618.     case OM_NEW:
  619.     if (o = (HObject *)HSuperMethod(o, cl, msg)) {
  620.         inst = HINST_DATA(o,cl);
  621.  
  622.         ti       = ((struct opSet *)msg)->ops_AttrList;
  623.         tstate = ti;
  624.         while (ti = NextTagItem(&tstate)) {
  625.         ULONG tg  = ti->ti_Tag;
  626.         ULONG val = ti->ti_Data;
  627.         switch (tg) {
  628.  
  629.         case HA_DropAction: {
  630.             inst->DropAction = strrep (inst->DropAction, (STRPTR)ti->ti_Data);
  631.         } break;
  632.  
  633.         case HA_ClickAction: {
  634.             inst->ClickAction = strrep (inst->ClickAction, (STRPTR)ti->ti_Data);
  635.         } break;
  636.  
  637.         case HA_Title: {
  638.             inst->IconTitle = strrep (inst->IconTitle, (STRPTR)ti->ti_Data);
  639.         } break;
  640.  
  641.         case HA_IconFile: {
  642.             inst->IconFile = strrep (inst->IconFile, (STRPTR)ti->ti_Data);
  643.         } break;
  644.  
  645.         } /* switch */
  646.         } /* while */
  647.  
  648.     } /* if */
  649.     return (ULONG)o;
  650.  
  651.     case OM_DISPOSE:
  652.     if (inst->Status == VISIBLE)
  653.         APIC_Hide (inst);
  654.  
  655.     if (inst->DiskObject)
  656.         FreeDiskObject(inst->DiskObject);
  657.     inst->DiskObject = NULL;
  658.  
  659.     if (inst->IconFile)
  660.         free(inst->IconFile);
  661.     inst->IconFile = NULL;
  662.  
  663.     if (inst->IconTitle)
  664.         free(inst->IconTitle);
  665.     inst->IconTitle = NULL;
  666.  
  667.     if (inst->DropAction)
  668.         free(inst->DropAction);
  669.     inst->DropAction = NULL;
  670.  
  671.     if (inst->ClickAction)
  672.         free(inst->ClickAction);
  673.     inst->ClickAction = NULL;
  674.  
  675.     return HSuperMethod (o,cl,msg);
  676.  
  677.     case OM_SET:
  678.     ti     = ((struct opSet *)msg)->ops_AttrList;
  679.     tstate = ti;
  680.     while (ti = NextTagItem(&tstate)) {
  681.         ULONG tg  = ti->ti_Tag;
  682.         ULONG val = ti->ti_Data;
  683.         switch (tg) {
  684.  
  685.         case HA_DropAction: {
  686.         inst->DropAction = strrep (inst->DropAction, (STRPTR)ti->ti_Data);
  687.         } break;
  688.  
  689.         case HA_ClickAction: {
  690.         inst->ClickAction = strrep (inst->ClickAction, (STRPTR)ti->ti_Data);
  691.         } break;
  692.  
  693.         case HA_Title: {
  694.         inst->IconTitle = strrep (inst->IconTitle, (STRPTR)ti->ti_Data);
  695.         } break;
  696.  
  697.         case HA_IconFile: {
  698.         inst->IconFile = strrep (inst->IconFile, (STRPTR)ti->ti_Data);
  699.         } break;
  700.  
  701.         case HA_Visible: {
  702.         if (!(ti->ti_Data) || *(ULONG *)ti->ti_Data == '0')
  703.             APIC_Hide(inst);
  704.         else
  705.             APIC_Show(inst);
  706.         } break;
  707.  
  708.         } /* switch */
  709.     } /* while */
  710.  
  711.     return HSuperMethod (o,cl,msg);
  712.  
  713.     case OM_GET:
  714.     switch (tg = ((struct opGet *)msg)->opg_AttrID) {
  715.  
  716.     case HA_DropAction: {
  717.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->DropAction;
  718.     } break;
  719.  
  720.     case HA_ClickAction: {
  721.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->ClickAction;
  722.     } break;
  723.  
  724.     case HA_IconTitle: {
  725.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->IconTitle;
  726.     } break;
  727.  
  728.     case HA_IconFile: {
  729.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->IconFile;
  730.     } break;
  731.  
  732.     case HA_Visible: {
  733.         *((struct opGet *)msg)->opg_Storage = inst->IconStatus;
  734.     } break;
  735.  
  736.     default:
  737.         return HSuperMethod(o, cl, msg);
  738.     } /* switch */
  739.  
  740.     return 1;
  741.  
  742.     default:
  743.     return HSuperMethod(o, cl, msg);
  744.     } /* switch */
  745.  
  746. } /* APIC_Dispatcher */
  747.  
  748.  
  749.  
  750. class appicon = {
  751.     superclass = rootclass;
  752.  
  753.     contents = {
  754.     slot IconTitle = {
  755.         type    = "UBYTE *";
  756.         dispose = {{
  757.         if (inst->IconTitle)
  758.             free (inst->IconTitle);
  759.         inst->IconTitle = NULL;
  760.         }};
  761.     };
  762.     slot IconFile = {
  763.         type = "UBYTE *";
  764.         dispose = {{
  765.         if (inst->IconFile)
  766.             free (inst->IconFile);
  767.         inst->IconFile = NULL;
  768.         }};
  769.     };
  770.     slot DropAction = {
  771.         type = "UBYTE *";
  772.         dispose = {{
  773.         if (inst->DropAction)
  774.             free (inst->DropAction);
  775.         inst->DropAction = NULL;
  776.         }};
  777.     };
  778.     slot ClickAction = {
  779.         type = "UBYTE *";
  780.         dispose = {{
  781.         if (inst->ClickAction)
  782.             free (inst->ClickAction);
  783.         inst->ClickAction = NULL;
  784.         }};
  785.     };
  786.     slot DiskObject = {
  787.         type = "struct DiskObject *";
  788.         dispose = {{
  789.         if (inst->DiskObject)
  790.             FreeDiskObject(inst->DiskObject);
  791.         inst->DiskObject = NULL;
  792.         }};
  793.     };
  794.     slot _Icon = {
  795.         type = "APTR";
  796.         dispose = {{
  797.         if (inst->_Icon)
  798.             RemoveAppIcon(inst->_Icon);
  799.         inst->_Icon = NULL;
  800.         }};
  801.     };
  802.     };
  803.  
  804.     attribute HA_DropAction = {{
  805.     type      = "STRPTR";
  806.     reference = "inst->DropAction"
  807.     I = {{
  808.         inst->DropAction = strrep (inst->DropAction, (STRPTR)ti->ti_Data);
  809.     }};
  810.     S = {{
  811.         inst->DropAction = strrep (inst->DropAction, (STRPTR)ti->ti_Data);
  812.     }};
  813.     G = {{
  814.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->DropAction;
  815.     }};
  816.     };
  817.  
  818.     attribute HA_ClickAction = {{
  819.     type      = "STRPTR";
  820.     reference = "inst->ClickAction"
  821.     I = {{
  822.         inst->ClickAction = strrep (inst->ClickAction, (STRPTR)ti->ti_Data);
  823.     }};
  824.     S = {{
  825.         inst->ClickAction = strrep (inst->ClickAction, (STRPTR)ti->ti_Data);
  826.     }};
  827.     G = {{
  828.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->ClickAction;
  829.     }};
  830.     };
  831.  
  832.     attribute HA_IconTitle = {{
  833.     type      = "STRPTR";
  834.     reference = "inst->IconTitle"
  835.     I = {{
  836.         inst->IconTitle = strrep (inst->IconTitle, (STRPTR)ti->ti_Data);
  837.     }};
  838.     S = {{
  839.         inst->IconTitle = strrep (inst->IconTitle, (STRPTR)ti->ti_Data);
  840.     }};
  841.     G = {{
  842.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->IconTitle;
  843.     }};
  844.     };
  845.  
  846.     attribute HA_IconFile = {{
  847.     type      = "STRPTR";
  848.     reference = "inst->IconFile"
  849.     I = {{
  850.         inst->IconFile = strrep (inst->IconFile, (STRPTR)ti->ti_Data);
  851.     }};
  852.     S = {{
  853.         inst->IconFile = strrep (inst->IconFile, (STRPTR)ti->ti_Data);
  854.     }};
  855.     G = {{
  856.         *((struct opGet *)msg)->opg_Storage = (ULONG)inst->IconFile;
  857.     }};
  858.     };
  859.  
  860.     attribute HA_Visible = {{
  861.     type = "BOOL";
  862.     S = {{
  863.         if (!(ti->ti_Data) /*|| (*(ULONG *)ti->ti_Data == '0') */)
  864.         APIC_Hide(inst);
  865.         else
  866.         APIC_Show(inst);
  867.     }};
  868.     G = {{
  869.         *((struct opGet *)msg)->opg_Storage = (inst->_Icon != NULL);
  870.     }};
  871.     };
  872. };
  873.  
  874.  
  875.  
  876.  
  877. #endif
  878.